package com.xyht.sca_s.student_manage_system.modules.employmentApplication.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.employmentApplication.entity.vo.SmsEmploymentApplicationAllowVO;
import com.xyht.sca_s.student_manage_system.modules.employmentApplication.entity.vo.SmsEmploymentApplicationCancelVO;
import com.xyht.sca_s.student_manage_system.modules.employmentApplication.entity.vo.SmsEmploymentApplicationVO;
import com.xyht.sca_s.student_manage_system.modules.employmentApplication.service.SmsEmploymentApplicationService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-05-23
 */
@RestController
@RequestMapping("/employmentApplication/smsEmploymentApplication")
@SecretBody
public class SmsEmploymentApplicationController {
    @Autowired
    SmsEmploymentApplicationService smsEmploymentApplicationService;
    @Autowired
    JwtTokenUtil jwtTokenUtil;
    @ApiModelProperty(value = "新增入职申请")
    @PostMapping("/add")
    public ResponseResult smsEmploymentApplication(@RequestBody SmsEmploymentApplicationVO smsEmploymentApplicationVO,
                                                   HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsEmploymentApplicationService.smsEmploymentApplication(smsEmploymentApplicationVO,user_id);
    }

    @ApiModelProperty(value = "撤销入职申请")
    @PostMapping("/cancel")
    public ResponseResult smsEmploymentApplicationCancel(@RequestBody SmsEmploymentApplicationCancelVO cancelVO,
                                                         HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsEmploymentApplicationService.smsEmploymentApplicationCancel(cancelVO,user_id);
    }

    @ApiModelProperty(value = "审批")
    @PostMapping("/allow")
    public ResponseResult smsEmploymentApplicationAllow(@RequestBody SmsEmploymentApplicationAllowVO allowVO,
                                                        HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsEmploymentApplicationService.smsEmploymentApplicationAllow(allowVO,user_id);
    }

    @ApiModelProperty(value = "审批列表")
    @GetMapping("/list")
    public ResponseResult smsEmploymentApplicationList(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                                       @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                       @RequestParam(value = "application_type") Integer application_type,
                                                       HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsEmploymentApplicationService.smsEmploymentApplicationList(pageSize,pageNum,application_type,user_id);
    }

    @ApiModelProperty(value = "审批详情")
    @GetMapping("/detail")
    public ResponseResult smsEmploymentApplicationDetail(@RequestParam(value = "application_id") String application_id,
                                                  HttpServletRequest request) {
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsEmploymentApplicationService.smsEmploymentApplicationDetail(application_id,user_id);
    }

    @ApiModelProperty(value = "申请人指定流程（申请前获取）")
    @GetMapping("/processList")
    public ResponseResult getSmsEmploymentApplicationOriginSettingProcess() {
        return smsEmploymentApplicationService.getSmsEmploymentApplicationOriginSettingProcess();
    }
}

